﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Vortex.Drawing {

	/// <summary>
	/// Object which contains information about 2D translation
	/// </summary>
	public class Translation : ITransform {
		private Vector2 _offset;

		/// <summary>
		/// Initializes a new instance of the <see cref="Translation"/> class.
		/// </summary>
		/// <param name="offset">The offset vector.</param>
		public Translation(Vector2 offset) {
			_offset = offset;
		}

		/// <summary>
		/// Initializes a new instance of the <see cref="Translation"/> class.
		/// </summary>
		/// <param name="x">The x coord of offset.</param>
		/// <param name="y">The y coord of offset.</param>
		public Translation(float x, float y) {
			_offset.X = x;
			_offset.Y = y;
		}

		/// <summary>
		/// Gets or sets the translation offset.
		/// </summary>
		/// <value>The offset.</value>
		public Vector2 Offset {
			get { return _offset; }
			set { _offset = value; }
		}

		/// <summary>
		/// Gets or sets the X coordinate of offset.
		/// </summary>
		/// <value>The X offset coord.</value>
		public float OffsetX {
			get { return _offset.X; }
			set { _offset.X = value; }
		}

		/// <summary>
		/// Gets or sets the Y coordinate of offset.
		/// </summary>
		/// <value>The Y offset coord.</value>
		public float OffsetY {
			get { return _offset.Y; }
			set { _offset.Y = value; }
		}

		/// <summary>
		/// Gets the empty translation.
		/// </summary>
		/// <value>The empty translation.</value>
		public static Translation Empty {
			get { return new Translation(Vector2.Zero); }
		}

		#region ITransform Members

		/// <summary>
		/// Gets the transform which represents this translation.
		/// </summary>
		/// <param name="transform">The transform represented by this translation.</param>
		public void GetTransform(out Transform2D transform) {
			Transform2D.CreateTranslation(ref _offset, out transform);
		}

		#endregion
	}
}
